@extends('layouts.app')

@section('content')
<div class="container" style="margin-bottom:50px;overflow:hidden;">
    <div class="row">
    	<div class="col-xs-12 bgOragin listTopContent clear">
	    	<!-- <a href="#activityIntro"  data-toggle="modal" data-target="#myModalName"> -->
	    		<div class=" fl">
	    			<div class="list-photoBox fl">
	    				<!-- <img src="{{ asset('images/saber.png') }}" alt="" class="list-photo textLeft"> -->
	    				@if(empty($activity->user->avatar))
	                    <img src="{{ asset('images/who.jpg') }}" class="list-photo textLeft"/>
	                    @else
	                    <img src="{{ $activity->user->avatar }}" class="list-photo textLeft"/>
	                    @endif
	    			</div>
	    		</div>
	    		<div class="col-xs-10 fl padTop02 colorWhite">
	    			<div class="fontSize14 liHeight underlinePb">{{$activity->name}}</div>
	    			<div class="fontSize12">由<span class="fontSize14 underlineBlack">{{$activity->one->name}}</span>发起</div>
					<a data-toggle="modal" href="javascript:void(0)" data-target="#myModalName" class="tdUnderline fr" style="color: #fff;position: relative;top: -38px;padding: 2px 5px;">
						<span>活动介绍</span>
					</a>
	    		</div>
	    	<!-- </a> -->
    	</div>
    	<div class="row bgBlack clear fontSize12">
    	<div class="liHeight borBotDash col-xs-12 textIndent ">起止时间：<?php echo date('Y-m-d H:i',$activity->start_time)?>-<?php echo date('Y-m-d H:i',$activity->end_time) ?></div>
    		<div class="blackBoxList col-xs-12 borBot textAlign">
    			<div class="borRightWh col-xs-3 fl"><span class="fontSize13">活动状态</span><br>{{$activity->activityStatus[$activity->status]}}</div>
    			<div class="borRightWh fl col-xs-3 "><span class="fontSize13">奖池金额</span><br>{{$activity->total_price}}</div>
    			<div class="borRightWh fl col-xs-3"><span class="fontSize13">已参加</span><br>{{$activity->people}}</div>
    			<div class="fl col-xs-3"><span class="fontSize13">发起金额</span><br>{{$activity->money}}</div>
    		</div>
    	</div>
    	<!--活动介绍框-->
    	<div class="modal fade" id="myModalName" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"  style="display:none">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" 
									aria-hidden="true">×
							</button>
							<h4 class="modal-title textLeft" id="myModalLabel">
								活动介绍
							</h4>
						</div>
						<div class="modal-body textAlign">
							{{ $activity->profile }}
						</div>
					</div>
				</div>
			</div>
    </div>
   
    <div class="row clear borBotD mb01">
    	<div class="panel panel-default" style="border:0;">
		  <div class="panel-heading textAlign fontSize14 col-xs-12" id="erweima"  style="border:0;line-height: 40px;">
		  	<div class="col-xs-4 borRight textLeft" style="border-right:1px solid #ddd">
		  		<a class="" href="{{url('/stockrules',array('id'=>$activity->id))}}" style="color:#333"><img src="{{ asset('images/rules.png') }}" alt="" width="14" height="14" style="margin-right:0px;" />活动规则</a>
		  	</div>
		  	<div data-toggle="modal" data-target="#myModal" class="col-xs-5 textAlign" style="border-right:1px solid #ddd">
				<a href="javascript:void(0)" style="color:#333;"><img src="{{ asset('images/icon-erweima.png') }}" alt="" width="14" height="14"  style="margin-right:3px;"/>发起人名片</a>
			</div>
			<div class="col-xs-3 textAlign">
				<a class="" href="{{url('show_activity',array('id'=>$activity->id))}}" style="color:#333"><img src="{{ asset('images/refresh.png') }}" alt="" width="14" height="14"  style="margin-right:3px;"/>刷新</a>
			</div>
			<!--模态框二维码start-->
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"  style="display:none">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" 
									aria-hidden="true">×
							</button>
							<h4 class="modal-title textLeft" id="myModalLabel">
								发起人名片
							</h4>
						</div>
						<div class="modal-body textAlign">
							@if(empty($activity->user->business_card))
			               		发起人还未设置名片
			                @else
			                <!-- <img src="{{ $activity->user->business_card }}" alt="Avatar"/> -->
			                <img src="{{ asset($activity->user->business_card) }}" alt="" width="200" height="200" class="textAlign">
			                @endif
							
						</div>
					</div>
				</div>
			</div>
			<!--模态框二维码end-->
		  </div>
		</div>
	</div>
		<div class="fontSize12 infoListBox">
			
			@foreach($orders as $k=>$order)
			<div class="row">
				<div class="borTop bgWhite mb01">
		  			<!-- <div class=" list-nameBox clear ">
			  			<p class="textLeft fl "><img src="{{ asset('images/saber.png') }}" alt="" class="list-name mr01">{{ $order->user->name }}</p>
			  			<p class="textRight verAlign fr mr01"> <span class="borderRadiusBg textAlign">{{ $k+1 }}</span></p>
		  			</div> -->
		  			<div class=" list-nameBox clear " style="padding:5px 0 8px 0">
		  				<p class="textAlign fl "  style="width:10%"><span class="borderRadiusBg textAlign" style="margin-top:5px;">{{ $k+1 }}</span></p>
			  			<p class="textLeft fl overNowrap" style="width:60%;">
			  				<!-- <img src="{{ asset('images/saber.png') }}" alt="" class="list-name mr01"> -->
			  				@if(empty($order->user->avatar))
		                    <img src="{{ asset('images/who.jpg') }}" class="list-name mr01"/>
		                    @else
		                    <img src="{{ $order->user->avatar }}" class="list-name mr01"/>
		                    @endif
		                    @if(!preg_match('/^1[3|4|5|7|8][0-9]\d{8}$/', $order->user->name))
			  				{{ $order->user->name }}
			  				@else
			  				{{ substr_replace($order->user->name,"***",4,3) }}
			  				@endif
			  			</p>
			  			@if( $order->reward() )
			  			<p class="textAlign verAlign fr" style="width:30%">
			  				
			  				<img src="{{ asset('images/prize02.png') }}" alt="" width="20" class="verAlign">
			  				<span style="color:#fe6703;" class="verAlign">{{ $order->reward()->money }}元</span>
			  			</p>
			  			@endif
		  			</div>

					

		  			<table class=" table  bgWhite col-xs-12" style="margin-bottom:10px;">
		  				@if($activity->status>0 || (!empty(Auth::user()) && Auth::user()->id==$order->user_id))
		  				<tr>
					  		<td data-field="name"><span  class="name">{{ $order->stock_name }}</span><br><span class="numCode">{{ $order->stock_code }}</span></td>
					  		<td data-field="kaipan"><span class="colorRed kaipan">{{ $order->open_price }}</span>开盘价</td>
					  		<td data-field="shoupan"><span class="colorRed shoupan">{{ $order->close_price }}</span><br>最新价</td>
					  		@if($order->yield>0)
					  		<td data-field="upOrDown"><span class="icon-up colorRed upOrDown">{{ $order->yield }}%</span></td>
				  			@else
				  			<td data-field="upOrDown"><span class="icon-down colorDown upOrDown">{{ $order->yield }}%</span></td>
				  			@endif

				  		</tr>
				  		@else
						<tr>
					  		<td >{{ $order->payment_time }}参与活动</td>
					  		
				  		</tr>
				  		@endif
		  			</table>
	  			</div>
			</div>
			@endforeach

			<!-- <div class="row">
				<div class="borTop bgWhite mb01">
		  			<div class=" list-nameBox clear ">
			  			<p class="textLeft fl "><img src="{{ asset('images/saber.png') }}" alt="" class="list-name mr01">小疯子</p>
			  			<p class="textRight verAlign fr mr01">排名 <span class="borderRadiusBg textAlign">1</span></p>
		  			</div>
		  			<table class=" table  bgWhite col-xs-12" style="margin-bottom:10px;">
		  				<tr>
					  		<td data-field="name"><span  class="name">平安银行</span><br><span class="numCode">111</span></td>
					  		<td data-field="kaipan"><span class="colorRed kaipan">0.00</span>开盘价</td>
					  		<td data-field="shoupan"><span class="colorRed shoupan">0.00</span><br>收盘价</td>
					  		<td data-field="upOrDown"><span class="icon-up colorRed upOrDown">0.00</span></td>
				  		</tr>
		  			</table>
	  			</div>
			</div>
			<div class="row">
				<div class="borTop bgWhite mb01">
		  			<div class=" list-nameBox clear ">
			  			<p class="textLeft fl "><img src="{{ asset('images/saber.png') }}" alt="" class="list-name mr01">小疯子</p>
			  			<p class="textRight verAlign fr mr01">排名 <span class="borderRadiusBg textAlign">2</span></p>
		  			</div>
		  			<table class=" table  bgWhite col-xs-12" style="margin-bottom:10px;">
		  				<tr>
					  		<td data-field="name"><span  class="name">平安银行</span><br><span class="numCode">0000</span></td>
					  		<td data-field="kaipan"><span class="colorRed kaipan">0.00</span>开盘价</td>
					  		<td data-field="shoupan"><span class="colorRed shoupan">0.00</span><br>收盘价</td>
					  		<td data-field="upOrDown"><span class="icon-up colorRed upOrDown">0.00</span></td>
				  		</tr>
		  			</table>
	  			</div>
			</div>
			<div class="row">
				<div class="borTop bgWhite mb01">
		  			<div class=" list-nameBox clear ">
			  			<p class="textLeft fl "><img src="{{ asset('images/saber.png') }}" alt="" class="list-name mr01">小疯子</p>
			  			<p class="textRight verAlign fr mr01">排名 <span class="borderRadiusBg textAlign">3</span></p>
		  			</div>
		  			<table class=" table  bgWhite col-xs-12" style="margin-bottom:10px;">
		  				<tr>
					  		<td data-field="name"><span  class="name">平安银行</span><br><span class="numCode">000</span></td>
					  		<td data-field="kaipan"><span class="colorRed kaipan">0.00</span>开盘价</td>
					  		<td data-field="shoupan"><span class="colorRed shoupan">0.00</span><br>收盘价</td>
					  		<td data-field="upOrDown"><span class="icon-down colorRed upOrDown">0.00</span></td>
				  		</tr>
		  			</table>
	  			</div>
			</div>
			<div class="row">
				<div class="borTop bgWhite mb01">
		  			<div class=" list-nameBox clear ">
			  			<p class="textLeft fl "><img src="{{ asset('images/saber.png') }}" alt="" class="list-name mr01">小疯子</p>
			  			<p class="textRight verAlign fr mr01">排名 3</p>
		  			</div>
		  			<table class=" table  bgWhite col-xs-12" style="margin-bottom:10px;">
		  				<tr>
					  		<td data-field="name"><span  class="name">平安银行</span><br><span class="numCode">000</span></td>
					  		<td data-field="kaipan"><span class="colorRed kaipan">0.00</span>开盘价</td>
					  		<td data-field="shoupan"><span class="colorRed shoupan">0.00</span><br>收盘价</td>
					  		<td data-field="upOrDown"><span class="icon-down colorRed upOrDown">0.00</span></td>
				  		</tr>
		  			</table>
	  			</div>
			</div> -->
		</div>
		<!--分页加载更多-->
		<!-- <div class="textAlign liHeight tdUnderline "><a href="javascript:" class="coloSty2">加载更多</a></div> -->

		<div class="listFixedBg">
			<div class="listFixed">
				<form class="form-inline" role="form">
					<div class="input-group col-xs-12">
					  <input type="number" class="form-control" placeholder="搜索股票代码" id="gp-search">
					  <a class="input-group-addon bgOragin" id="join" href="javascript:void(0)">参与活动</a>
					</div>
					<div class="input-droup search-content" style="display:none">
						
					</div>
				</form>
			</div>
		</div>
	



    	
    <script>  
	$(function(){
		
		$("#gp-search").keyup(function(event){
			var searchVal = $("#gp-search").val();
			$.ajax({
			type:"get",
			url:"{{url('/test',array('code'=>''))}}/"+searchVal,
			async:false,
			// data:{searchVal:"searchVal"},
			success:function(result){
				var data = JSON.parse(result);
				var content ="";
				$.each(data,function(key,val){
                    content+='<ul class="search-info">'
					 		+'<li><span class="mr01">'+val.name+'</span><span class="ticker">'+val.code+'</span></li></ul>';
                })
				$(".search-content").html(content);
				$('li').click(function(){
					var spanText = $(this).find(".ticker").text();
				    $('#gp-search').val(spanText);
				});
			}
		});
		});
		$("#gp-search").click(function(event){
			$(".search-content").show();

			event.stopPropagation();//阻止事件冒泡
		});
		$(".search-content .search-info li").click(function(event){
			var li = $(this).text();
			$("#gp-search").val(li);
			$(".search-content").fadeOut();
			event.stopPropagation();//阻止事件冒泡
		});
		$('body').on('click',function(){
			$(document).click(function(){
			    $(".search-content").hide();
			});
		});

		$("#join").click(function(){
			var money='{{$activity->money}}';
			var activity_id='{{$activity->id}}';
			var code=$("#gp-search").val();
			if(!code){
				alert('请填写股票代码');
				return false;
			}
			$.ajax({
				type:'post',
				data:{money:money,activity_id:activity_id,code:code},
				url:"{{url('create_order')}}",
				success:function(data){
					if(data.status==1){
						alert(data.msg);
						return false;
					}
					window.location.href='{{url('sure_pay')}}/'+data.id;
				}
			})
		})
	});
	</script>
</div>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    wx.config(<?php echo $js->config(array('onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ', 'onMenuShareWeibo'), false) ?>);
    wx.ready(function(){
	    wx.onMenuShareTimeline({
		    title: "[对对乐]{{ $activity->name }}", // 分享标题
		    link: "{{ url('/show_activity',['id'=>$activity->id]) }}", // 分享链接
		    imgUrl: "{{ $activity->user->avatar }}", // 分享图标
		    success: function () { 
		        // 用户确认分享后执行的回调函数
		    },
		    cancel: function () { 
		        // 用户取消分享后执行的回调函数
		    }
		});

	    wx.onMenuShareAppMessage({
		    title:  "[对对乐]{{ $activity->name }}", // 分享标题
		    desc: "{{ $activity->profile }}", // 分享描述
		    link: "{{ url('/show_activity',['id'=>$activity->id]) }}", // 分享链接
		    imgUrl: "{{ $activity->user->avatar }}", // 分享图标
		    type: '', // 分享类型,music、video或link，不填默认为link
		    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
		    success: function () { 
		        // 用户确认分享后执行的回调函数
		    },
		    cancel: function () { 
		        // 用户取消分享后执行的回调函数
		    }
		});
	});
</script>

@endsection
